class Solution {
public:
    bool findTargetIn2DPlants(vector<vector<int>>& plants, int target) {
        int n = plants.size();
        if (!n)return 0;
        int m = plants[0].size();
        if (!m)return 0;
        int i = 0, j = m - 1;
        while (i < n && j >= 0) {
            if (plants[i][j] == target)return 1;
            else if (plants[i][j] < target)i++;
            else j--;
        }
        return 0;
    }
};